/*
 * extdrv/include/hi_ssp.h for Linux .
 *
 * History:
 *      2006-4-11 create this file
 */
#ifndef __HI_SSP_H__
#define __HI_SSP_H__

#define SSP_LCD_SET_BRIGHTNESS          0x11
#define SSP_LCD_SET_BACKLIGHT           0x12
#define SSP_LCD_SET_DISPLAY             0x13

#define ST7789V_CMD_SLPOUT					0x11			/* sleep out */

/*
Bit D7- Page Address Order
“0” = Top to Bottom (When MADCTL D7=”0”).
“1” = Bottom to Top (When MADCTL D7=”1”).
Bit D6- Column Address Order
“0” = Left to Right (When MADCTL D6=”0”).
“1” = Right to Left (When MADCTL D6=”1”).
Bit D5- Page/Column Order
“0” = Normal Mode (When MADCTL D5=”0”).
“1” = Reverse Mode (When MADCTL D5=”1”)
Note: Bits D7 to D5, alse refer to section 8.12 Address Control
Bit D4- Line Address Order
“0” = LCD Refresh Top to Bottom (When MADCTL D4=”0”)
“1” = LCD Refresh Bottom to Top (When MADCTL D4=”1”)
Bit D3- RGB/BGR Order
“0” = RGB (When MADCTL D3=”0”)
“1” = BGR (When MADCTL D3=”1”)
Bit D2- Display Data Latch Data Order
“0” = LCD Refresh Left to Right (When MADCTL D2=”0”)
“1” = LCD Refresh Right to Left (When MADCTL D2=”1”)
*/
#define ST7789V_CMD_MADCTL					0x36			/* Memory Data Access Control */

#define ST7789V_CMD_COLMOD					0x3a


/*
D7 D6 D5 D4 D3 D2 D1 D0
1st parameter 0 BPA6 BPA5 BPA4 BPA3 BPA2 BPA1 BPA0
2nd parameter 0 FPA6 FPA5 FPA4 FPA3 FPA2 FPA1 FPA0
3rd parameter 0 0 0 0 0 0 0 PSEN
4th parameter  BPB3 BPB2 BPB1 BPB0 FPB3 FPB2 FPB1 FPB0
5th parameter  BPC3 BPC2 BPC1 BPC0 FPC3 FPC2 FPC1 FPC0

BPA[6:0]: Back porch setting in normal mode. The minimum setting is 0x01.
FPA[6:0]: Front porch setting in normal mode. The minimum setting is 0x01.
PSEN: Enable separate porch control.
	PSEN Mode
	0 Disable separate porch control
	1 Enable separate porch control
BPB[3:0]: Back porch setting in idle mode. The minimum setting is 0x01.
FPB[3:0]: Front porch setting in idle mode. The minimum setting is 0x01.
BPC[3:0]: Back porch setting in partial mode. The minimum setting is 0x01.
FPC[3:0]: Front porch setting in partial mode. The minimum setting is 0x01.
*/
#define ST7789V_CMD_PORCTRL					0xb2			/* Porch Setting */

/*
	电压有关
	0 VGHS2 VGHS1 VGHS0 0 VGLS2 VGLS1 VGLS0
*/
#define ST7789V_CMD_GCTRL					0xb7			/* Gate Control */

/*
	电压有关
	0 0 VCOM5 VCOM4 VCOM3 VCOM2 VCOM1 VCOM0
*/
#define ST7789V_CMD_VCOMS					0xbb			/* VCOM Setting */

/*
	0 XMY XBGR XINV XMX XMH XMV XGS
*/
#define ST7789V_CMD_LCMCTRL					0xc0			/* LCM Control */


/* linux */

#define ST7789V_COLMOD_RGB_FMT_18BITS		(6 << 4)
#define ST7789V_COLMOD_CTRL_FMT_18BITS		(6 << 0)

#define ST7789V_RAMCTRL_CMD		0xb0
#define ST7789V_RAMCTRL_RM_RGB			BIT(4)
#define ST7789V_RAMCTRL_DM_RGB			BIT(0)
#define ST7789V_RAMCTRL_MAGIC			(3 << 6)
#define ST7789V_RAMCTRL_EPF(n)			(((n) & 3) << 4)

#define ST7789V_RGBCTRL_CMD		0xb1
#define ST7789V_RGBCTRL_WO			BIT(7)
#define ST7789V_RGBCTRL_RCM(n)			(((n) & 3) << 5)
#define ST7789V_RGBCTRL_VSYNC_HIGH		BIT(3)
#define ST7789V_RGBCTRL_HSYNC_HIGH		BIT(2)
#define ST7789V_RGBCTRL_PCLK_HIGH		BIT(1)
#define ST7789V_RGBCTRL_VBP(n)			((n) & 0x7f)
#define ST7789V_RGBCTRL_HBP(n)			((n) & 0x1f)

#define ST7789V_PORCTRL_CMD		0xb2
#define ST7789V_PORCTRL_IDLE_BP(n)		(((n) & 0xf) << 4)
#define ST7789V_PORCTRL_IDLE_FP(n)		((n) & 0xf)
#define ST7789V_PORCTRL_PARTIAL_BP(n)		(((n) & 0xf) << 4)
#define ST7789V_PORCTRL_PARTIAL_FP(n)		((n) & 0xf)

#define ST7789V_GCTRL_CMD		0xb7
#define ST7789V_GCTRL_VGHS(n)			(((n) & 7) << 4)
#define ST7789V_GCTRL_VGLS(n)			((n) & 7)

#define ST7789V_VCOMS_CMD		0xbb

#define ST7789V_LCMCTRL_CMD		0xc0
#define ST7789V_LCMCTRL_XBGR			BIT(5)
#define ST7789V_LCMCTRL_XMX			BIT(3)
#define ST7789V_LCMCTRL_XMH			BIT(2)

#define ST7789V_VDVVRHEN_CMD		0xc2
#define ST7789V_VDVVRHEN_CMDEN			BIT(0)

#define ST7789V_VRHS_CMD		0xc3

#define ST7789V_VDVS_CMD		0xc4

#define ST7789V_FRCTRL2_CMD		0xc6

#define ST7789V_PWCTRL1_CMD		0xd0
#define ST7789V_PWCTRL1_MAGIC			0xa4
#define ST7789V_PWCTRL1_AVDD(n)			(((n) & 3) << 6)
#define ST7789V_PWCTRL1_AVCL(n)			(((n) & 3) << 4)
#define ST7789V_PWCTRL1_VDS(n)			((n) & 3)

#define ST7789V_PVGAMCTRL_CMD		0xe0
#define ST7789V_PVGAMCTRL_JP0(n)		(((n) & 3) << 4)
#define ST7789V_PVGAMCTRL_JP1(n)		(((n) & 3) << 4)
#define ST7789V_PVGAMCTRL_VP0(n)		((n) & 0xf)
#define ST7789V_PVGAMCTRL_VP1(n)		((n) & 0x3f)
#define ST7789V_PVGAMCTRL_VP2(n)		((n) & 0x3f)
#define ST7789V_PVGAMCTRL_VP4(n)		((n) & 0x1f)
#define ST7789V_PVGAMCTRL_VP6(n)		((n) & 0x1f)
#define ST7789V_PVGAMCTRL_VP13(n)		((n) & 0xf)
#define ST7789V_PVGAMCTRL_VP20(n)		((n) & 0x7f)
#define ST7789V_PVGAMCTRL_VP27(n)		((n) & 7)
#define ST7789V_PVGAMCTRL_VP36(n)		(((n) & 7) << 4)
#define ST7789V_PVGAMCTRL_VP43(n)		((n) & 0x7f)
#define ST7789V_PVGAMCTRL_VP50(n)		((n) & 0xf)
#define ST7789V_PVGAMCTRL_VP57(n)		((n) & 0x1f)
#define ST7789V_PVGAMCTRL_VP59(n)		((n) & 0x1f)
#define ST7789V_PVGAMCTRL_VP61(n)		((n) & 0x3f)
#define ST7789V_PVGAMCTRL_VP62(n)		((n) & 0x3f)
#define ST7789V_PVGAMCTRL_VP63(n)		(((n) & 0xf) << 4)

#define ST7789V_NVGAMCTRL_CMD		0xe1
#define ST7789V_NVGAMCTRL_JN0(n)		(((n) & 3) << 4)
#define ST7789V_NVGAMCTRL_JN1(n)		(((n) & 3) << 4)
#define ST7789V_NVGAMCTRL_VN0(n)		((n) & 0xf)
#define ST7789V_NVGAMCTRL_VN1(n)		((n) & 0x3f)
#define ST7789V_NVGAMCTRL_VN2(n)		((n) & 0x3f)
#define ST7789V_NVGAMCTRL_VN4(n)		((n) & 0x1f)
#define ST7789V_NVGAMCTRL_VN6(n)		((n) & 0x1f)
#define ST7789V_NVGAMCTRL_VN13(n)		((n) & 0xf)
#define ST7789V_NVGAMCTRL_VN20(n)		((n) & 0x7f)
#define ST7789V_NVGAMCTRL_VN27(n)		((n) & 7)
#define ST7789V_NVGAMCTRL_VN36(n)		(((n) & 7) << 4)
#define ST7789V_NVGAMCTRL_VN43(n)		((n) & 0x7f)
#define ST7789V_NVGAMCTRL_VN50(n)		((n) & 0xf)
#define ST7789V_NVGAMCTRL_VN57(n)		((n) & 0x1f)
#define ST7789V_NVGAMCTRL_VN59(n)		((n) & 0x1f)
#define ST7789V_NVGAMCTRL_VN61(n)		((n) & 0x3f)
#define ST7789V_NVGAMCTRL_VN62(n)		((n) & 0x3f)
#define ST7789V_NVGAMCTRL_VN63(n)		(((n) & 0xf) << 4)





#endif
